<template>
    <div class="box">
        <div class="top">
            <p class="title">未来七天游客趋势图</p>
            <p class="bg"></p>
        </div>
        <div class="charts" ref="line"></div>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
//引入echarts
import * as echarts from 'echarts';
let line = ref();
//组件挂载完毕初始化图形图标
onMounted(()=>{
    let mycharts=echarts.init(line.value);
    //设置配置项
    mycharts.setOption({
        //标题组件
        title:{
            text:'访问量'
        },
        //x|y轴
        xAxis:{
            type:'category',//在x轴均匀分布
            boundaryGap:false,//x轴两侧不留白
            splitLine:{
                show:false
            },
            //轴线设置
            axisLine:{
                show:true
            },
            //坐标轴刻度
            axisTick:{
                show:true
            },
            data:['周一','周二','周三','周四','周五','周六','周日']
        },
        yAxis:{
            splitLine:{
                show:false
            },
            //轴线设置
            axisLine:{
                show:true
            },
            //坐标轴刻度
            axisTick:{
                show:true
            }
        },
        //调整图形图标的位置
        grid: {
            left: 40,
            top: 0,
            right: 20,
            bottom: 20
        },
        //系列
        series:[
            {
                type:'line',
                data:[120,866,133,3188,999,2929,500],
                //平滑曲线的设置
                smooth :true,
                areaStyle:{
                    color:// 线性渐变，前四个参数分别是 x0, y0, x2, y2, 范围从 0 - 1，相当于在图形包围盒中的百分比，如果 globalCoord 为 `true`，则该四个值是绝对的像素位置
                {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'red' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'rgb(28, 101, 192)' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                },
                }
            }
        ]
    })

})
</script>

<style lang="scss" scoped>
.box{
    width:100%;
    height:100%;
    background: url(../../images/dataScreen-main-lb.png) no-repeat;
    background-size: 100% 100%;
    margin-top: 20px;
    margin-left: 20px;
    margin-bottom: 10px;
    .top {
        margin-left: 20px;

        .title {
            margin-left: 40px;
            color: white;
            font-size: 20px;
        };

        .bg {
            margin-left: 40px;
            width: 68px;
            height: 7px;
            background: url(../../images/dataScreen-title.png) no-repeat;
            background-size: 100% 100%;
            margin-top: 10px;
        };
    }
    .charts{
        height:calc(100% - 30px);
    }
}
</style>
